<style>
	.btn {padding: 0;}
	.CGridViewContainer { 
		width: 100%;   
		overflow: auto;    
		scrollbar-base-color:#ffeaff 
	}
</style>
<?php
$this->breadcrumbs=array(
	'Projects',
);
$acc = UserModule::isAdmin();
if($acc == true ){
	$this->menu=array(
		array('label'=>UserModule::t('Manage Users'), 'url'=>array('/user/admin')),
		array('label'=>UserModule::t('Manage Profile Field'), 'url'=>array('/user/profileField/admin')),
		array('label'=>UserModule::t('List User'), 'url'=>array('/user')),
		array('label'=>'Manage Project', 'url'=>array('/user/project')),
		array('label'=>'Manage Content', 'url'=>array('/master/content')),
		array('label'=>UserModule::t('Logout'), 'url'=>array('/user/logout')),
	);
}else{
$this->menu=array(
		array('label'=>UserModule::t('Profile'), 'url'=>array('/user/profile')),
		array('label'=>UserModule::t('Edit'), 'url'=>array('/user/profile/edit')),
		array('label'=>UserModule::t('Change password'), 'url'=>array('/user/profile/changepassword')),
		array('label'=>'Project', 'url'=>array('/user/project')),
		array('label'=>UserModule::t('Logout'), 'url'=>array('/user/logout')),
	);
}
?>

<h1>Projects</h1>
<hr />

<?php 
$this->beginWidget('zii.widgets.CPortlet', array(
	'htmlOptions'=>array(
		'class'=>''
	)
));
$this->widget('bootstrap.widgets.TbMenu', array(
	'type'=>'pills',
	'items'=>array(
		array('label'=>'Create', 'icon'=>'icon-plus', 'url'=>Yii::app()->controller->createUrl('create'), 'linkOptions'=>array()),
        array('label'=>'List', 'icon'=>'icon-th-list', 'url'=>Yii::app()->controller->createUrl('index'),'active'=>true, 'linkOptions'=>array()),
	),
));
$this->endWidget();
?>

<div class="CGridViewContainer">
<?php 
if(Yii::app()->user->checkAccess('admin')){
	$this->widget('bootstrap.widgets.TbGridView',array(
		'id'=>'project-grid',
		'dataProvider'=>$model->search(),
		'htmlOptions'=>array('style'=>'width: 1500px'),
		'filter'=>$model,
			'type'=>'striped bordered condensed',
			'template'=>'{summary}{pager}{items}{pager}',
		'columns'=>array(
			array(
				'header'=>'No.',
				'value'=>'$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)',
			),
			array(
				'name' => 'userId',
				'value' => 'User::model()->findByPk($data->userId)->username',
				'filter' => CHtml::listData(User::model()->findAll(array('condition'=>'id > 1','order' => 'username')), 'id', 'username'),
			),
			'name',
			array(
				'name'=>'status',
				'value'=>'Yii::app()->helper->statusApprove($data->status)',
				'filter' => array(1=>'Approve',2=>'Not Yet',3=>'Not Approve'),
			),
			array(
				'name' => 'province_id',
				'value' => 'Province::model()->findByPk($data->province_id)->name',
				'filter' => CHtml::listData(Province::model()->findAll(array('order' => 'name')), 'id', 'name'),
			),
			'finance_range',
			array(
				'name' => 'file_path',
				'type'=>'raw',
				'value' => 'CHtml::link($data->file_path,Yii::app()->baseUrl."/upload/".$data->file_path)',
			),
			'created_date',
			'updated_date',
		   array(
				'class'=>'bootstrap.widgets.TbButtonColumn',
				'template' => '{view} {update} {delete}',
				'buttons' => array(
					  'view' => array(
						'label'=> 'View',
						'options'=>array(
							'class'=>'btn btn-small view'
						)
					),	
								  'update' => array(
						'label'=> 'Update',
						'options'=>array(
							'class'=>'btn btn-small update'
						)
					),
					'delete' => array(
						'label'=> 'Delete',
						'options'=>array(
							'class'=>'btn btn-small delete'
						)
					)
				),
				'htmlOptions' => array('width' => '80', 'textAlign' => 'center'),
			   )
		),
	)); 
}else {
	$this->widget('bootstrap.widgets.TbGridView',array(
		'id'=>'project-grid',
		'dataProvider'=>$model->search(),
		'filter'=>$model,
			'type'=>'striped bordered condensed',
			'template'=>'{summary}{pager}{items}{pager}',
		'columns'=>array(
			array(
				'header'=>'No.',
				'value'=>'$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)',
			),
			'name',
			array(
				'name'=>'status',
				'value'=>'Yii::app()->helper->statusApprove($data->status)',
				'filter' => array(1=>'Approve',2=>'Not Yet',3=>'Not Approve'),
			),
			array(
				'name' => 'province_id',
				'value' => 'Province::model()->findByPk($data->province_id)->name',
				'filter' => CHtml::listData(Province::model()->findAll(array('order' => 'name')), 'id', 'name'),
			),
			'finance_range',
			array(
				'name' => 'file_path',
				'type'=>'raw',
				'value' => 'CHtml::link($data->file_path,Yii::app()->baseUrl."/upload/".$data->file_path)',
			),
		   array(
				'class'=>'bootstrap.widgets.TbButtonColumn',
				'template' => '{view} {update} {delete}',
				'buttons' => array(
					  'view' => array(
						'label'=> 'View',
						'options'=>array(
							'class'=>'btn btn-small view'
						)
					),	
								  'update' => array(
						'label'=> 'Update',
						'options'=>array(
							'class'=>'btn btn-small update'
						)
					),
					'delete' => array(
						'label'=> 'Delete',
						'options'=>array(
							'class'=>'btn btn-small delete'
						)
					)
				),
				'htmlOptions' => array('width' => '80', 'textAlign' => 'center'),
			   )
		),
	)); 
}
?>
</div>
